<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>公告中心</title>
    <link rel="stylesheet" href="css/notice.css">
    <script src="js/jquery-1.10.1.min.js"></script>
</head>
<body>
<div class="title">
    <i class="iconfont">&#xe613;</i>
    <p>公告中心</p>
</div>
<ul class="continer">

</ul>
</body>
<script type="text/javascript">

    window.onload = function () {
        $(".iconfont").click(function () {
            if( localStorage.uid===0) {
                window.location.href = "index.html";
            }else {
                window.location.href = "../personal/index.html";
            }
        })

    }
    $(function(){
        $.ajax({
            url: `${localStorage.top}api/index/notice_list?TOKEN=${localStorage.token}`,    //请求的url地址
            dataType: "json",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "GET",   //请求方式
            success: function (data) {
             console.log(data)
                //请求成功时处理
                var html='';
                for (var i = 0; i < data.data.length; i++) {
                    html+= `<li class='notice-list' id="`+data.data[i].article_id+`">
                   <div class='list-number'><div class='list-img'><img src='images/laba.png' alt=''></div>
                   <div class='list-text'><h4>`+data.data[i].title+`</h4><p>`+data.data[i].time_text+`</p></div> </div></li>`;

                };

                $(".continer").html(html);

                $('.continer').find('li').each(function(){
                    $(this).click(function(){
                        window.location.href='notice-details.html';
                        localStorage.id=this.id;
                        localStorage.uid=1;
                    })
                })

            }
        })

    });
</script>
</html>